import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/index.vue'
import Login from '@/views/login/index.vue'
import Home from '@/views/home/home.vue'
import { List } from 'echarts'
// 异步加载
const Product =()=>import('@/views/product/product.vue') 
const Category=()=>import('@/views/product/category/category.vue')
const Lists=()=>import('@/views/product/list/list.vue')
Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    component:Layout,
    children:[
        {
          path:'/',
          name:'home',
          component:Home
        },
        {
          path:'/product',
          name:'product',
          component:Product,
          children:[
            {
              path:'list', // 此处/代表访问根路径，此处为三级路由
              name:'list',
              component:Lists
            },
            {
              path:'category', // 此处/代表访问根路径，此处为三级路由
              name:'category',
              component:Category
            }
          ]
        }
  ]
  },{
    path:'/login',
    component:Login
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
